<include file="../Public/_header" />
<div class="so_main">
  <div class="page_tit">销售信息管理</div>
  <!-------- 搜索用户 -------->
  <div id="searchGoods_div" <neq name="type" value="searchUser">style="display:none;"</neq>>
  	<div class="page_tit">搜索商品 [ <a href="javascript:void(0);" onclick="searchGoods();">隐藏</a> ]</div>
	
	<div class="form2">
	<form method="post" action="{:U('admin/Shop/soGoods')}">
    <dl class="lineD">
      <dt>标题/关键字：</dt>
      <dd>
        <input name="title" id="title" type="text" value="{$title}">

      </dd>
    </dl>
	
    <dl class="lineD">
      <dt>用户/发布人：</dt>
      <dd>
        <input name="uname" id="uname" type="text" value="{$uname}">
      </dd>
    </dl>
	
    <dl class="lineD">
      <dt>发布时间/创建时间：</dt>
      <dd>
        <input name="ctime" id="ctime" type="text" value="">
      </dd>
    </dl>
    <div class="page_btm">
      <input type="submit" class="btn_b" value="确定" />
    </div>
	</form>
    
  </div>
</div>
  
  <!-------- 用户列表 -------->
  <div class="Toolbar_inbox">
  	<div class="page right">{$page}</div>
	<a href="javascript:void(0);" class="btn_a" onclick="searchUser();">
		<span class="searchUser_action"><neq name="type" value="searchUser">搜索商品<else/>搜索完毕</neq></span>
	</a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteGoods();"><span>删除商品</span></a>
  </div>
  <div class="list">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
		<input type="checkbox" id="checkbox_handle" onclick="checkAll(this)" value="0">
    	<label for="checkbox"></label>
	</th>
    <th class="line_l">ID</th>
    <th class="line_l">用户信息</th>
    <th class="line_l">标题</th>
    <th class="line_l">发布时间</th>
    <th class="line_l">操作</th>
    <th class="line_l">操作</th>
  </tr>
  <volist id="vo" name="goodslist">
	  <tr overstyle='on' id="goods_{$vo['id']}">
	  	<td>
	    	<input type="checkbox" name="checkbox" id="checkbox2" onclick="checkon(this)" value="{$vo.id}"></td>
	    
	    <td>{$vo.id}</td>
	    <td>{$vo['uname']}</td>
		<td>
			<a href="{:U('shop/Index/goods',array('uid'=>$vo['uid'],'gid'=>$vo['id']))}">{$vo['title']}</a>
		</td>
	    <td>
			{$vo.ctime|date="Y-m-d H:i",###}
			
		</td>     </td>
	    <td>编辑 <a href="javascript:void(0);" onclick="deleteGoods({$vo['id']});">删除</a></td>
	    <td>编辑 删除</td>
	  </tr>
  </volist>
  </table>
</div>

  <div class="Toolbar_inbox">
	<div class="page right">{$page}</div>
	<a href="javascript:void(0);" class="btn_a" onclick="searchUser();">
		<span class="searchUser_action"><neq name="type" value="searchGoods">搜索商品<else/>搜索完毕</neq></span>
	</a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteGoods();"><span>删除商品</span></a>
  </div>
</div>

<script>
	//鼠标移动表格效果
	$(document).ready(function(){
		$("tr[overstyle='on']").hover(
		  function () {
		    $(this).addClass("bg_hover");
		  },
		  function () {
		    $(this).removeClass("bg_hover");
		  }
		);
	});
	
	function checkon(o){
		if( o.checked == true ){
			$(o).parents('tr').addClass('bg_on') ;
		}else{
			$(o).parents('tr').removeClass('bg_on') ;
		}
	}
	
	function checkAll(o){
		if( o.checked == true ){
			$('input[name="checkbox"]').attr('checked','true');
			$('tr[overstyle="on"]').addClass("bg_on");
		}else{
			$('input[name="checkbox"]').removeAttr('checked');
			$('tr[overstyle="on"]').removeClass("bg_on");
		}
	}

	//获取已选择销售信息的ID数组
	function getChecked() {
		var goods_ids = new Array();
		$.each($('table input:checked'), function(i, n){
			goods_ids.push( $(n).val() );
		});
		return goods_ids;
	}

	//删除销售信息
	function deleteGoods(goods_id) {
		goods_id = goods_id ? goods_id : getChecked();
		goods_id = goods_id.toString();
		if(goods_id == '' || !confirm('删除成功后将无法恢复，确认继续？')) return false;
		
		$.get("{:U('admin/Shop/dodelGoods')}", {goods_id:goods_id}, function(res){
			if(res == '1') {
				goods_id = goods_id.split(',');
				for(i = 0; i < goods_id.length; i++) {
					$('#goods_'+goods_id[i]).remove();
				}
				ui.success('操作成功');
			}else {
				ui.error('操作失败');
			}
		});
	}
	
	//搜索用户
	var isSearchHidden = <neq name="type" value="searchGoods">1<else/>0</neq>;
	function searchUser() {
		if(isSearchHidden == 1) {
			$("#searchGoods_div").slideDown("fast");
			$(".searchUser_action").html("搜索完毕");
			isSearchHidden = 0;
		}else {
			$("#searchGoods_div").slideUp("fast");
			$(".searchUser_action").html("搜索用户");
			isSearchHidden = 1;
		}
	}
	
	function folder(type, _this) {
		$('#search_'+type).slideToggle('fast');
		if ($(_this).html() == '展开') {
			$(_this).html('收起');
		}else {
			$(_this).html('展开');
		}
		
	}
</script>

<include file="../Public/_footer" />